package com.clei.dto.file;

/**
 * 文件差异
 *
 * @author Y
 * @date 2022-05-11
 */
public class FileDiff {

    /**
     * 文件路径1
     */
    private String filePath1;

    /**
     * 文件路径2
     */
    private String filePath2;

    /**
     * 差异类型 1文件不存在 2文本差异 3文件类型不一致
     */
    private Integer diffType;

    /**
     * 文本差异内容
     */
    private String diffContent;

    public FileDiff(String filePath1, String filePath2, Integer diffType, String diffContent) {
        this.filePath1 = filePath1;
        this.filePath2 = filePath2;
        this.diffType = diffType;
        this.diffContent = null == diffContent ? getDiffContent(diffType) : diffContent;
    }

    private String getDiffContent(Integer diffType) {
        return diffType == 3 ? "文件类型不一致" : null;
    }

    @Override
    public String toString() {
        return filePath1 + "  " + filePath2 + (null != diffContent ? '\n' + diffContent : "");
    }
}